package com.ruoyi.apis.service;

import com.ruoyi.apis.entity.SysConfigEnity;
import com.ruoyi.apis.repository.SysConfigRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author Choi
 * @Date 2021/10/15
 */

@Service
public class ISysConfigService {

    @Autowired
    private SysConfigRepository sysConfigRepository;

    public void updateClearConfig() {
        SysConfigEnity config = this.getClearConfig();
        config.setConfigValue("false");
        sysConfigRepository.save(config);
    }

    public SysConfigEnity getClearConfig() {
        SysConfigEnity config = sysConfigRepository.findByConfigKey("sys.config.clear");
        if (config == null) {
            config = new SysConfigEnity();
            config.setConfigName("清理缓存");
            config.setConfigKey("sys.config.clear");
            config.setConfigValue("false");
            config.setConfigType("N");
        }
        return config;
    }
}
